﻿export default function define(Blocks: Blockly.BlockDefinitions) {

  Blocks['webifinline'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('如果');
      this.appendValueInput("iftext")
        .setCheck("Boolean");
      this.appendDummyInput()
        .appendField('那么:');
      this.appendStatementInput('ifstate')
        .setCheck(null);
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#49B04D");
      this.setTooltip('If block with inline input');
      this.setHelpUrl('');
    },
  };

  Blocks['webelifinline'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('否则如果');
      this.appendValueInput('iftext')
        .setCheck(null)
      this.appendDummyInput()
        .appendField('那么:');
      this.appendStatementInput('ifstate')
        .setCheck(null);
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#49B04D");
      this.setTooltip('ElIf block with inline input');
      this.setHelpUrl('');
    },
  };

  Blocks['webelse'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('否则:');
      this.appendStatementInput('DO')
        .appendField('');
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#49B04D");
      this.setTooltip('Else statement');
      this.setHelpUrl('');
    },
  };
  
  Blocks['operators_2'] = {
    init: function() {
      this.appendValueInput("first")
          .setCheck(null);
      this.appendDummyInput()
        .appendField(new Blockly.FieldDropdown([["+","+"], ["-","-"], ["/","/"], ["%","%"], ["*","*"]]), "operators");
      this.appendValueInput("last")
          .setCheck(null);
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setColour("#49B04D");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };
  
  Blocks['webinternal'] = {
    init: function() {
          var ltrOperators = [
            ['==', '=='],
            ['!=', '!='],
            ['<', '<'],
            ['<=', '<='],
            ['>', '>'],
            ['>=', '>=']
          ];
          var OPERATORS = ltrOperators;
      this.appendValueInput("first")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(new Blockly.FieldDropdown(OPERATORS), "choose")
      this.appendValueInput("last")
          .setCheck(null);
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setColour("#49B04D");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blocks['webandor'] = {
    init: function() {
      this.appendValueInput("first")
          .setCheck(null);
      this.appendDummyInput()
          .appendField(new Blockly.FieldDropdown([["与", "and"], ["或", "or"]]), "choose")
      this.appendValueInput("last")
          .setCheck(null);
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setColour("#49B04D");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blocks['webnot'] = {
    init: function () {
      this.appendDummyInput()
        .appendField('非'); 
      this.appendValueInput("bool")
        .setCheck(null);
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setColour("#49B04D");
      this.setTooltip('negates a Boolean value');
      this.setHelpUrl('http://www.example.com/');
    },
  };
  
 Blocks['raspin'] = {
    init: function() {
      this.appendDummyInput()
          .appendField('字符串'); 
      this.appendValueInput("first")
          .setCheck(null);
      this.appendDummyInput()
          .appendField('是否包含'); 
      this.appendValueInput("last")
          .setCheck(null);
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setColour("#49B04D");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };
}

